Elephant Stout Elephant Elephant
The two string variables each get a string:
LET WORDA$ = "Elephant" LET WORDB$ = "Stout"
The first PRINT
statement prints out the characters in
each string variable (and puts a tab between them on the screen.)
PRINT WORDA$, WORDB$
Now the characters in WORDA$
are copied into WORDB$
,
replacing the old characters.
LET WORDB$ = WORDA$
Finally the new contents are printed out:
PRINT WORDA$, WORDB$
The INPUT
statement can
put characters into a string variable.
Here is a program that does that:
' Input with Strings ' PRINT "Please type your name and hit Enter" INPUT NAME$ PRINT "Your name is:", NAME$ END
When the INPUT
statement executes
the user types characters on the keyboard and
see them on the screen.
When Enter is hit, the characters are copied into
the string variable NAME$
.
Here is a run of the program:
Please type your name and hit Enter ? Irene Adler Your name is: Irene Adler
What do you think would happen with this program if the user hit Enter before typing anything?